using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InventhightLight : MonoBehaviour
{
    [SerializeField] RectTransform hightLight;

    public void show(bool b) {
        hightLight.gameObject.SetActive(b);
    }

    public void setSize(InventoryItem targetItem,ItemGrid itemGrid)
    {
        Vector2 size = new Vector2();
        if (itemGrid.ItemDataType == ItemDataType.normal)
        {
            size.x = targetItem.WIDTH * itemGrid.tileSizeWidth;
            size.y = targetItem.HEIGHT * itemGrid.tileSizeHeight;
        }
        else {
            size.x =  itemGrid.tileSizeWidth;
            size.y =  itemGrid.tileSizeHeight;
        }
       
        hightLight.sizeDelta = size;
    }

    public void setParent(ItemGrid targetGrid) {
        if (targetGrid == null) { return; }
        hightLight.SetParent(targetGrid.GetComponent<RectTransform>());
    }
    public void SetPosition(ItemGrid targetGrid, InventoryItem targetItem)
    {
        Vector2 pos = targetGrid.calculatePositionOnGrid(targetItem, targetItem.onGridPositionX, targetItem.onGridPositionY);
        hightLight.localPosition = pos;
    }

    public void SetPosition(ItemGrid targetGrid, InventoryItem targetItem,int posX,int posY)
    {
        Vector2 pos = targetGrid.calculatePositionOnGrid(targetItem, posX, posY);
        hightLight.localPosition = pos;
    }
}
